package Day14;

import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改
/**
 * 2021Java真题:山
 * https://www.lanqiao.cn/problems/2141/learning/
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int count = 0;
        for(int i = 2022; i <= 2022222022; i++){
            String s = i + "";
            if(isUp(s) && isHui(s)){
                count++;
            }
        }
        System.out.println(count);
        scan.close();
    }

    public static boolean isUp(String s){
        int n = s.length();
        char[] c = s.toCharArray();
        //注意，是奇数长度还是偶数长度
        int mid = n % 2 == 0 ? n / 2 : n / 2 + 1;
        for(int i = 1; i < mid; i++){
            if(c[i] < c[i - 1]){
                return false;
            }
        }
        return true;
    }

    

    public static boolean isHui(String s){
        StringBuffer str = new StringBuffer(s);
        return ((str.toString()).equals(str.reverse().toString()));
    }
}